package com.jxt.myjxtmanager.views;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;

/**
 * Created by qm on 2016/12/9 0009.
 */
public class MySetMaxHeightRecyclerView extends RecyclerView {

    private int recyclHeight = 300;

    public int getRecyclHeight() {
        return recyclHeight;
    }

    public void setRecyclHeight(int recyclHeight) {
        this.recyclHeight = recyclHeight;
    }

    public MySetMaxHeightRecyclerView(Context context) {
        super(context);
    }

    public MySetMaxHeightRecyclerView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MySetMaxHeightRecyclerView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    protected void onMeasure(int widthSpec, int heightSpec) {
        if (recyclHeight > -1) {
            heightSpec = MeasureSpec.makeMeasureSpec(recyclHeight, MeasureSpec.AT_MOST);
        }
        super.onMeasure(widthSpec, heightSpec);
    }
}
